package com.project.source;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;

public class IbanGeneratorActivity extends Activity {
	Spinner spinner ;
	EditText tvBankCode;
	EditText tvAccountNumber;
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main_generator);

	    spinner = (Spinner) findViewById(R.id.spinner);
	    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
	            this, R.array.country_array, android.R.layout.simple_spinner_item);
	    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
	    spinner.setAdapter(adapter);

		
	}
	
	public void GenerateIban(View V) {
		// TextView tv = (TextView) findViewById(R.id.result);
		int position =spinner.getSelectedItemPosition();
		tvBankCode=(EditText)findViewById(R.id.editText1); 
		String bankCode= tvBankCode.getText().toString();
		tvAccountNumber=(EditText)findViewById(R.id.editText2); 
		String  accountNumber= tvAccountNumber.getText().toString();
		String IsIBan = IbanValidator.IbanGenerator(bankCode, accountNumber, position);
		AlertDialog.Builder builder = new AlertDialog.Builder(this);
		
			builder.setMessage(IsIBan);

			

		builder.setCancelable(false).setNegativeButton("OK",
				new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int id) {
						dialog.cancel();
					}
				});
		builder.show();
	}
}
